package thread;

public class ThreadDemo11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 100_0000; i++) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        // 启动之前, 获取 t 的状态 (NEW)
        System.out.println("start 之前: " + t.getState());

        t.start();
        for (int i = 0; i < 1000; i++) {
            System.out.println("t 执行中的状态: " + t.getState());
        }
        t.join();

        // 线程执行完毕之后 (TERMINATE)
        System.out.println("t 结束之后: " + t.getState());
    }
}
